#include "stdafx.h"
#include "msg.h"
#include<iostream>
using namespace std;

netMsg NetMsgQueue::getNetMsg()
{
	if(netMsgQueue.size()>0)
	{
		netMsg nm=netMsgQueue.front();
		netMsgQueue.pop_front();
		return nm;
	}
	else
	{
		netMsg nm;
		nm.sock=0;
		nm.msg="";
		return nm;
	}

}

bool NetMsgQueue::addNetMsg(netMsg netmsg)
{
	cout<<"msg:"<<netmsg.sock<<":"<<netmsg.msg<<endl;
	netMsgQueue.push_back(netmsg);

	list<netMsg>::iterator it=netMsgQueue.begin();
	list<netMsg>::iterator itend=netMsgQueue.end();
	if(it!=itend)
		cout<<"first:"<<it->sock<<":"<<it->msg<<endl;
	for(;it!=itend;it++)
	{
		cout<<it->sock<<":"<<it->msg<<endl;
	}
	return true;
}

int NetMsgQueue::size() const
{
	return netMsgQueue.size();
}

list<netMsg>::iterator NetMsgQueue::begin()
{
	return netMsgQueue.begin();
}

list<netMsg>::iterator NetMsgQueue::end()
{
	return netMsgQueue.end();
}







